x86emul: rework CMP and TEST emulation
authorJan Beulich <jbeulich@suse.com>
Fri, 29 May 2020 15:28:45 +0000 (17:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 29 May 2020 15:28:45 +0000 (17:28 +0200)
commit20bc1b9cc99b70b17757e1903f629c7a26584790
tree0ab235673f682d8be296bd66e7288101c8c6a800
parente28d13eeb65c25c0bd56e8bfa83c7473047d778d
x86emul: rework CMP and TEST emulation

Unlike similarly encoded insns these don't write their memory operands,
and hence x86_is_mem_write() should return false for them. However,
rather than adding special logic there, rework how their emulation gets
done, by making decoding attributes properly describe the r/o nature of
their memory operands:
-  change the table entries for opcodes 0x38 and 0x39, with no other
   adjustments to the attributes later on,
-  for the other opcodes, leave the table entries as they are, and
   override the attributes for the specific sub-cases (identified by
   ModRM.reg).

For opcodes 0x38 and 0x39 the change of the table entries implies
changing the order of operands as passed to emulate_2op_SrcV(), hence
the splitting of the cases in the main switch().

Note how this also allows dropping custom LOCK prefix checks.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/x86_emulate/x86_emulate.c